﻿using UnityEngine;
using System.Collections.Generic;
using System;


/// <summary>
/// Produce State And Edit The Transition Condition 
/// </summary>
/// <typeparam name="StateType">may be PlayerState, EnemyState, etc</typeparam>
public class StateFactory<StateType> {
	public Dictionary<StateType, State<StateType>> States { get; set; } = new Dictionary<StateType, State<StateType>>();

	public void AddState(StateType type, State<StateType> state)
		=> States.Add(type, state);

	public State<StateType> GetState(StateType state) {
		if (States.ContainsKey(state)) return States[state];

#if UNITY_EDITOR
		Debug.LogError($"{state} not in Factory");
#endif

		return null;
	}


	public void AddConditionToSelf(StateType self, Func<bool> condition)
		=> States[self].AddConditionToSelf(condition);

	public void AddTransition(StateType from, StateType to, Func<bool> func)
		=> States[from].AddNewTransition(to, func);


	//Funs Below is Add Or Minus Conditions to Other States, But MayBe Will not use

	//public void AddTransCondition(StateType from, StateType to, Func<bool> func)
	//	=> States[from].AddNewTrasitionCondition(to, func);

	//public void MinusTransCondition(StateType from, StateType to, Func<bool> func)
	//	=> States[from].MinusTransitionCon(to, func);
}
